clear all
version 15
cd "_____"


set more off

use "./data/PM10CMLEresults_Stata16.dta", clear


gen manipdays=(Fxnp-Fxp)*totday
sort id year
//Table in Figure4C
list city year manipdays if id==7
//Table 2A
tabstat propFx manipdays, stat(count mean med sd min max)

sort id
by id: egen totalmissmanip=total(!mi(manipdays))

preserve
drop if totalmissmanip<10
list city year manipdays if id==7
by id: egen summanipdays=total(manipdays)
collapse summanipdays, by(id)
list summanipdays if id==7
//Table 2B total number of manipulated blue-sky days 2001-2010, cities reporting 2001-2010 
tabstat summanipdays, stat(count mean sd max)
egen summanipdaysmax=max(summanipdays)
list id if summanipdays==summanipdaysmax

restore


preserve
drop if year<2006
sort id
by id: egen totalmissmanip10=total(!mi(manipdays))
by id: egen summanipdays10=total(manipdays)

drop if totalmissmanip10<5
collapse summanipdays10, by(id)
//Table 2B total number of manipulated blue-sky days 2006-2010, all cities subject to data availability
tabstat summanipdays10, stat(count mean sd max)
egen summanipdaysmax10=max(summanipdays10)
list id if summanipdays10==summanipdaysmax10
restore

